package sklad;

import jxl.read.biff.BiffException;
import jxl.write.WriteException;

import java.io.IOException;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * User: Vladimir
 * Date: 23.09.12 Time: 19:23
 */
public class Main {
//    public static final String BASE_PATH = "G:\\projects\\my-im-tools\\sklad\\";
    public static final String BASE_PATH = "G:\\projects\\my-im-tools\\test\\";

    public static void main(String[] args) throws BiffException, IOException, ParseException, WriteException {
        StoreManager storage = new StoreManager();

        String inPath = BASE_PATH + "in-bills\\";
        String outPath = BASE_PATH + "out-bills\\";
        String sellsPath = BASE_PATH + "sells\\";

//        List<GoodItem> inItems = Parser.parseDir(inPath);
//        storage.incomeGoods(StoreEnum.SEDOVA, inItems);

//        Map<StoreEnum, List<GoodItem>> outItemsByStore = Parser.parseDirByStore(outPath);
//        storage.moveItems(StoreEnum.SEDOVA, outItemsByStore);

//        List<GoodItem> soldItems = Parser.parseXls(sellsPath + "post.xls");
//        storage.sellItems(StoreEnum.SEDOVA, soldItems);

//        soldItems = Parser.parseXls(sellsPath + "self.xls");
//        storage.sellItems(StoreEnum.SEDOVA, soldItems);

//        List<GoodItem> returnItems = Parser.parseXls(sellsPath + "self.xls");
//        storage.returnItems(StoreEnum.SEDOVA, soldItems);
//        List<GoodItem> rejectedItems = Parser.parseXls(sellsPath + "reject.xls");
//        storage.rejectItems(StoreEnum.SEDOVA, soldItems);

        Map<StoreEnum, List<GoodItem>> remains = Parser.parseRemainsDir(sellsPath);
        storage.resumeRemains(remains);
        storage.saveToXls(BASE_PATH + "остатки.xls");

        System.out.println(storage);
//        System.out.println(storage.allItems.size());

        System.out.println(storage);
        for (StoreEnum store : remains.keySet()) {
            List<GoodItem> items = remains.get(store);
            System.out.println(store.name + " : ");
            for (GoodItem item : items) {
                System.out.println(item);
            }
        }
    }
}
